<?php

/**
 * WEB端调用接口
 */
class My_ServiceController extends MM_Controller_My_Action
{   
	/**
	 * uploadfile
	 */
	public function uploadAction()
	{
		if ( ($this->uid<1) ) {
			$this->result = $this->returnResult(Mediad2_Model_Result::CODE_FAILURE,'Miss parameter: uid');
		} else {
			$upload_name = 'Filedata';
			$returnArray = true;
			$sourcetype = Mediad2_Model_Files::SOURCETYPE_WEB;
			$sourceid = $this->uid;
			$this->result = $this->service->upload($sourcetype, $sourceid, $upload_name, $returnArray);
		}
	
		echo $this->encodeResult($this->result);
	}
	
	/**
	 * download file
	 */
	public function downloadAction()
	{
		if (($this->uid<1) || ($this->fid<1) ) {
			$this->result = $this->returnResult(Mediad2_Model_Result::CODE_FAILURE,'Miss parameter: uid/fid...');
		} else {
			$this->result = $this->service->download($this->fid);
		}
	
		echo $this->encodeResult($this->result);
	}
	

}
	
	

	